package com.kai.steering.data.service.entity.domainObject;

import cn.hutool.core.bean.BeanUtil;
import com.kai.steering.data.service.entity.dto.UserQueryDTO;
import com.kai.steering.data.service.entity.po.Note;
import com.kai.steering.data.service.entity.po.Role;
import com.kai.steering.data.service.entity.po.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.Date;

import lombok.*;

import java.io.Serializable;
import java.util.List;

/**
 * <pre>
 * 用户 Do对象
 * </pre>
 *
 * @author kai
 * @date 2022-02-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserDO对象", description = "用户业务实体")
public class UserDO implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "账号")
    private String userId;
    @ApiModelProperty(value = "用户名")
    private String userName;
    @ApiModelProperty(value = "密码")
    private String password;
    @ApiModelProperty(value = "用户简介")
    private String introduce;
    @ApiModelProperty(value = "用户生日期")
    private Date birthday;
    @ApiModelProperty(value = "创建日期")
    private Date creationDatetime;
    @ApiModelProperty(value = "用户电话")
    private String phone;
    @ApiModelProperty(value = "用户地址")
    private String address;
    @ApiModelProperty(value = "存在0删除1")
    private Integer usable;
    @ApiModelProperty(value = "删除日期")
    private Date deleteDatetime;
    @ApiModelProperty(value = "仓库id")
    private String warehouseId;
    @ApiModelProperty(value = "仓库id")
    public List<RoleDO> roles;
    public UserDO(User user) {
        this.convertUserDO(user);
    }

    public UserDO(UserQueryDTO userQueryDTO) {
        this.convertUserDO(userQueryDTO);
    }

    /**
     * 转po为do
     * @param user
     * @return
     */
    public UserDO convertUserDO(User user){
        this.userId=user.getUserId();
        this.userName=user.getUserName();
        this.password=user.getPassword();
        this.introduce=user.getIntroduce();
        this.birthday=user.getBirthday();
        this.creationDatetime=user.getCreationDatetime();
        this.phone=user.getPhone();
        this.address=user.getAddress();
        this.usable=user.getUsable();
        this.deleteDatetime=user.getDeleteDatetime();
        return this;
    }
    /**
     * 转QueryDTO为do
     * @param userQueryDTO
     * @return
     */
    public UserDO convertUserDO(UserQueryDTO userQueryDTO){
        this.userId=userQueryDTO.getUserId();
        this.userName=userQueryDTO.getUserName();
        this.password=userQueryDTO.getPassword();
        this.introduce=userQueryDTO.getIntroduce();
        this.birthday=userQueryDTO.getBirthday();
        this.phone=userQueryDTO.getPhone();
        this.address=userQueryDTO.getAddress();
        return this;
    }
}